using System;
using System.IO;

namespace Servlets.Api
{
	public interface IBody
	{
		/// <summary>
		/// Will return the most relevant value paired with the given key.
		/// If a <see cref="Servlets.WebFile"/> is avalable it will be returned
		/// Else if a Value is avalable it will be returned
		/// Else the RawBody will be returned as an Immutable Byte array
		/// Note: The RawBody will only be returned if returning Value and returning File is not implemented.
		///       If they are implemented and neither of them contain the specified key, a <see cref="Servlets.Exception.InvalidKeyException"/> will be thrown
		/// </summary>
		/// <param name="key">
		/// A <see cref="System.String"/>
		/// </param>
		object this [string key]{get;}
		
		/// <summary>
		/// Returns the raw unparsed body as a byte[]
		/// </summary>
		byte[] RawBody{get;}
		
		/// <summary>
		/// Allows you to index into key/value pairs
		/// </summary>
		IValue<string> Value{get;}
		
		/// <summary>
		/// Allows you to index into key/value pairs of <see cref="Servlet.WebFile"/>
		/// </summary>
		IValue<WebFile> File{get;}
		
		/// <summary>
		/// Parses the stream.
		/// </summary>
		/// <param name="reader">
		/// A <see cref="StreamReader"/>
		/// </param>
		/// <param name="contentType">
		/// A <see cref="ContentType"/>
		/// </param>
		/// <param name="contentLength">
		/// A <see cref="System.Int32"/>
		/// </param>
		void ParseStream(StreamReader reader, string contentType, int contentLength);
	}
}

